#include "cybertron/sensor/noise/BiasNoise.hpp"

CYBERTRON_BEGIN

BiasNoise::BiasNoise(float bias/* = 0.01*/, bool bWithWhiteNoise/* = false*/)
	:NoiseBase(EBiasNoise), m_bias(bias)
{
	m_whiteNoisePtr = bWithWhiteNoise ? std::make_shared<WhiteNoise>(1.0f, 0.1f) : nullptr;
}

BiasNoise::BiasNoise(const vec2& bias, bool bWithWhiteNoise/* = false*/)
	: NoiseBase(EBiasNoise), m_bias(bias, 0.0)
{
	m_whiteNoisePtr = bWithWhiteNoise ? std::make_shared<WhiteNoise>(1.0f, 0.1f) : nullptr;
}

BiasNoise::BiasNoise(const vec3& bias, bool bWithWhiteNoise/* = false*/)
	: NoiseBase(EBiasNoise), m_bias(bias)
{
	m_whiteNoisePtr = bWithWhiteNoise ? std::make_shared<WhiteNoise>(1.0f, 0.1f) : nullptr;
}

BiasNoise::~BiasNoise()
{
}

vec3 BiasNoise::update() {
	m_value = m_whiteNoisePtr ? (m_bias * m_whiteNoisePtr->update()) : m_bias;
	return m_value;
}

void BiasNoise::setBias(const vec3& bias)
{
	m_bias = bias;
}

CYBERTRON_END